fis.hook('relative');
fis.config.set("project.watch.usePolling", true)
// 启用插件
fis.hook('relative');
fis.match('/outs/**', { release: false});

fis.match('/static/styles/(style.less)', {
  parser: fis.plugin('less-2.x',{
    dumpLineNumbers: "comments",
  }),
  release: '/static/styles/$1',
  rExt: '.css'
});
// 处理img标签, 将holder.js替换为data-src,使其在控制台不报错
fis.match('*.html', {
  parser: function(content, file, settings) {
    return content.replace(/<img\s.*?>/gi, function(all) {
      if ( /holder\.js/.test(all) && !/data-src/.test(all) )
        return all.replace(/src/, function(src) { return 'data-src'; });
      else
        return all;
    })
  }
});
// 打包输出
fis.media('prod')
// un release
  .match('/outs/**', { release: false })
  // style release
  .match('/static/styles/(**.less)', { release: false })
  .match('/static/styles/(style.less)', {
    parser: fis.plugin('less-2.x'),
    optimizer: fis.plugin('clean-css', {
      keepBreaks: true,
    }),
    useSprite: true,
    release: 'static/styles/all_style.css',
    rExt: '.css'
  })
  // images release
  .match('/static/images/(**)', {
    release: 'static/images/$1'
  })
  // script release
  .match('js/(*.js)', {
    optimizer: fis.plugin('uglify-js', {
      mangle: {
        except: 'exports, module, require, define'
      }
    }),
    packTo: '/static/all_script.js'
  })
  // special set
  .match('**', {
    relative: true,
    deploy: fis.plugin('local-deliver', {
      to: './outs'
    })
  })